package com.aegis.core.manager;


import com.aegis.core.constants.AegisTokenRedisConstants;
import com.aegis.core.model.AegisSession;
import com.aegis.core.model.HashScanResult;
import com.aegis.core.model.ScanResult;

import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @Author wuweixin
 *
 * @Version 1.0
 * @Descritube 这里是做数据清洗的，不要直接调用
 */
public class AegisDataCleanManager {

    public static final long EXPIRE_TIME_SEC = 1000 * 60 * 60 * 24L;

    private AegisDataCleanManager() {
        throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
    }

    public static void setLoginUser(String appId, Object userId, AegisSession aegisSession) {
        AegisComponentManager.getAegisDao().hset(AegisTokenRedisConstants.getDataCleanLoginUser(appId), userId + "", aegisSession, EXPIRE_TIME_SEC);
    }


    public static <T> void scanLoginUser(String appId,
                                         int batchSize,
                                         Function<HashScanResult<T>, Boolean> function) {
        AegisComponentManager.getAegisDao()
                .scanHash(AegisTokenRedisConstants.getDataCleanLoginUser(appId), batchSize, "*", function);
    }


}
